<template>
    <div class="login-container">
        <div class="login-form">
            <h1 class="login-title">照心健康体检APP——医生登录</h1>
                <div class="form-group">
                    <label for="doctorCode"> 请输入医生编码: </label>
                    <input id="doctorCode" v-model="form.doccode" type="text" required />
                </div>
                <div class="form-group">
                    <label for="password"> 请输入密码: </label>
                    <input id="password" v-model="form.password" type="password" required />
                </div>
                <div class="button-group">
                    <button type="submit" class="create-button" @click="login">login in</button>
                </div>

            <div class="footer">
                <p class="copyright">@Neusoft 2024年09月24日</p>
                <div class="yellow-circle"></div>
            </div>
        </div>
    </div>
</template>
<script setup>
import { setSessionStorage } from "../utils/common";
import { useRouter } from "vue-router";
import {reactive, ref} from "vue";
import axios from "axios";

const router = useRouter();
let form = reactive({});
const login = async () => {
    await axios.post("/api/doctor/login", form).then((res) => {
        console.log(res);
        if (res.data.status == 200) {
            setSessionStorage("doctor", res.data.data);
            router.push("/reports");
        } else {
            alert("登录失败，请重试");
        }
        // 登录成功，跳转到首页
    });
};
</script>
<style scoped>
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #3388ff;
    position: relative;
    transition: background-color 0.3s; /* 背景颜色渐变效果 */
}

.notification {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
}

.notification-icon {
    margin-right: 10px;
}

.notification-text {
    color: #4caf50;
}

.login-form {
    background-color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-radius: 5px;
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-title {
    font-size: 18px;
    font-weight: normal;
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e8e8e8;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-size: 14px;
    color: #333;
    margin-bottom: 5px;
}

.form-group input {
    display: block;
    width: 100%;
    padding: 8px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 14px;
}

.button-group {
    display: flex;
    justify-content: flex-start;
    margin-top: 20px;
}

.create-button,
.cancel-button {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}

.create-button {
    background-color: #1890ff;
    color: white;
    border: none;
    margin-right: 10px;
}

.cancel-button {
    background-color: white;
    color: #333;
    border: 1px solid #d9d9d9;
}

.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
}

.copyright {
    font-size: 12px;
    color: #888;
}

.yellow-circle {
    width: 20px;
    height: 20px;
    background-color: #ffeb3b;
    border-radius: 50%;
}
</style>
